import * as mongoose from 'mongoose';
const Schema = mongoose.Schema;
export const NavigationMenuSchema = new Schema({
    iconUrl: {
        type: String,
        required: true,
        trim: true
    },
    link: {
        type: String,
        required: true,
        trim: true
    },
    title: {
        type: String,
        required: true,
        trim: true
    },
    isActive: {
        type: Boolean,
        default: true
    },
    order: {
        type: Number,
        default: 100
    }
}, {
    timestamps: true,//当保存文档的时候自动创建createAt和updateAt两个字段，启用时间戳
    toJSON: {//定制toJSON方法，当文件转成JSON格式的时候调用
        virtuals: true,//启动虚拟属性
        //定义转换函数，用于修改文档 的JSON表现形式
        transform(doc, ret) {
            //把_id转成id
            ret.id = ret._id.toHexString();
            //删除掉原来的_id
            delete ret._id;
            //删除掉原来的__v
            delete ret.__v;
        }
    }
})